package com.jy.event.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SuiXingFuResult {
    private String code;

    private String msg;

    private RespData respData;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RespData {
        private String bizCode;

        private String bizMsg;
        private double recFeeAmtTotal;

        private List<SettleInfo> settleInfo = new ArrayList<>();


        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class SettleInfo {
            private String serialNo;

            private double amount;

            private double fee;
        }
    }


    public boolean isSuccess() {
        return "0000".equalsIgnoreCase(code) && "00".equalsIgnoreCase(respData.getBizCode());
    }

    public double getTotalAmount() {
        double r = 0.0;
        for (RespData.SettleInfo info : respData.getSettleInfo()) {
            r += info.getAmount();
        }
        return r;
    }

    public double getTotalFee() {
        return respData.getRecFeeAmtTotal();
    }
}
